<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <style>
  .box {
      width: 600px;
      height: 600px;
      border: 1px solid red;
  }
  </style>
</head>
<body>

<div class="box" id="box"></div>
<div>
    当前鼠标位置: 
    <span id="pos"></span>
</div>

<script src="https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.20/lodash.js"></script>
<script>
var throttle_my = (fn, delay = 500) => {
    let timer;
    return (...args) => {
        if (timer != undefined) return;
        timer = setTimeout(() => {
            fn.apply(this, args);
            timer = clearTimeout(timer)
        }, delay);
    }
}

var handle = (event) => {
        // console.log(event.x, event.y)
        document.getElementById('pos').innerHTML = `${event.x},${event.y}`
    }

    // document.getElementById('box').addEventListener('mousemove', _.throttle(handle, 150));
    document.getElementById('box').addEventListener('mousemove', throttle_my(handle, 150));
</script>
</body>
</html>